package com.ztmg.water.controller.system;

import com.ztmg.common.util.resultUtils.JsonResult;;
import com.ztmg.water.model.system.SysUser;
import com.ztmg.water.vo.common.CommonFlag;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageInfo;


import com.ztmg.water.vo.system.SysUserVO;
import com.ztmg.water.dto.system.SysUserDTO;
import com.ztmg.water.dto.system.SysUserPageDTO;
import com.ztmg.water.service.system.SysUserService;

import java.util.List;


/**
 * 
 * SysUserControllerController
 * 
 **/

@Api(description = "用户接口")
@RestController
@RequestMapping(value = "/sysUser")
public class SysUserController{

	@Resource
	private SysUserService sysUserService;

    @PostMapping("login")
    @ApiOperation("登录")
    public JsonResult<SysUserVO> login(@RequestBody SysUserDTO dto){
        return sysUserService.loginValidate(dto);
    }
    @PostMapping("create")
    @ApiOperation("新增")
    public JsonResult create(@RequestBody SysUserDTO dto){
        return sysUserService.create(dto);
    }

    @PostMapping("update")
    @ApiOperation("修改")
    public JsonResult update(@RequestBody SysUserDTO dto){
        return sysUserService.update(dto);
    }

    @GetMapping("detail/{id}")
    @ApiOperation("详情")
    public JsonResult<SysUserVO> detail(@PathVariable Integer id){
        return sysUserService.selectById(id);
    }

    @PostMapping("select")
    @ApiOperation("条件查询")
    public JsonResult<SysUserVO> detail(@RequestBody SysUserDTO dto){
        return sysUserService.select(dto);
    }

    @PostMapping("queryPage")
    @ApiOperation("分页查询")
    public JsonResult<PageInfo<SysUserVO>> queryPage(@RequestBody SysUserPageDTO dto){
        return sysUserService.selectPage(dto);
    }

    @PostMapping("delete")
    @ApiOperation("条件删除")
    public JsonResult delete(@RequestBody SysUserDTO dto){
        return sysUserService.delete(dto);
    }

    @GetMapping("deleteById/{id}")
    @ApiOperation("删除")
    public JsonResult deleteById(@PathVariable Integer id){
        return sysUserService.deleteById(id);
    }
    @PostMapping("batchDelete")
    @ApiOperation("批量删除")
    public JsonResult batchDelete(@RequestBody List<Integer> ids){
        return sysUserService.batchDelete(ids);
    }
}